﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Threading.Tasks.Dataflow;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace SearchAlgorithms.Services
{
    public class ConsoleBlock
    {
        public class ConsoleResultBlock//显示对比结果
        {
            public ActionBlock<(bool, int)> _InputBlock;
            public Action<List<string>> DataArrived;
            public ConsoleResultBlock()
            {

                _InputBlock = new ActionBlock<(bool, int)>(results =>
                {
                    List<string> message = new List<string>();
                    bool re = results.Item1;
                    int framenumber = results.Item2;
                    
                    if (!re)
                    {
                        message.Add($"第 {framenumber} 帧不同");
                    }

                    
                    DataArrived?.Invoke(message);
                });
            }

            public void Enqueue((bool, int) input)
            {
                _InputBlock.Post(input);
            }
        }
    }
}